//
//  YZVideoPreVC.m
//  VET
//
//  Created by YZ on 2018/7/16.
//  Copyright © 2018年 YZ. All rights reserved.
//

#import "YZVideoPreVC.h"
#import "YZActionSheet.h"

@interface YZVideoPreVC ()<YZActionSheetDelegate>

@property (nonatomic, strong) UIButton *deleteBtn;

@end

@implementation YZVideoPreVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self.view addSubview:self.deleteBtn];
    
    [self.deleteBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(kCurrentDeviceNum(30));
        make.size.mas_equalTo(CGSizeMake(kCurrentDeviceNum(28), kCurrentDeviceNum(28)));
        make.right.equalTo(self.view.mas_right).offset(-kCurrentDeviceNum(30));
    }];
}

- (void)viewDidLayoutSubviews
{
    [super viewDidLayoutSubviews];
    [self.view bringSubviewToFront:self.deleteBtn];
}

- (void)deleteBtnClicked
{
    YZActionSheet *sheet = [[YZActionSheet alloc] initWithTitle:@"你确定要删除这个视频吗？" sheetTitles:@[@"确认"] cancleBtnTitle:@"取消" sheetStyle:YZActionSheetDefault delegate:self];
    sheet.titleColor = kColorWithHex(0x9B9B9B);
    sheet.titleFont = kCurrentDeviceFont(16);
    sheet.subtitleColor = kColorWithHex(0xFF5656);
    sheet.subtitleFont = sheet.titleFont;
    [sheet show];
}

#pragma mark -- YZActionSheetDelegate

- (void)actionSheet:(YZActionSheet *)actionSheet clickButtonAtIndex:(NSInteger)buttonIndex
{
    if (_delegate && [_delegate respondsToSelector:@selector(deleteCurrentVideoAssert)]) {
        [_delegate deleteCurrentVideoAssert];
    }
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (UIButton *)deleteBtn
{
    if (!_deleteBtn) {
        _deleteBtn = [UIButton new];
        [_deleteBtn setImage:[UIImage imageNamed:@"ico_delete"] forState:UIControlStateNormal];
        [_deleteBtn addTarget:self action:@selector(deleteBtnClicked) forControlEvents:UIControlEventTouchUpInside];
    }
    return _deleteBtn;
}
@end
